package cate.game.role.res.guild.msg.member.pos;

import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdGuild;
import cate.game.role.Role;
import easy.java.dev.note.NoteField;
import org.apache.commons.lang3.StringUtils;

@ClientMsg(title = "申请加入公会 の 请求")
public class GuildJoinReq implements MsgInput {
    @NoteField(value = "公会Id")
    public String guildId;

    @Override
    public MsgConfig conf() {
        return MsgIdGuild.GUILD_JOIN_REQ;
    }

    @Override
    public void execute(GameBody game, ClientContext cc) {
        Role role = cc.getRole();
        if (!role.getRes().guild.checkGuild().ok()) {
            game.res.guild.action.applyJoinGuild(role, guildId);
        } else {
            if (StringUtils.equals(role.getRes().guild.uid, guildId)) {
                game.notice.message(role,310468,"您已加入该公会");
            } else {
                game.notice.message(role,310469,"您已加入其他公会");
            }
        }
    }
}
